#include <bits/stdc++.h>
using namespace std;
#define N 50005
int n, m, t;
string s[N];
map<string, int> mp;

int main()
{
	string tmp;
	cin >> n >> m >> t;
	for (int i = 1; i <= n; i++)
	{
		cin >> tmp;
		s[i] = tmp;
		mp[tmp] = i;
	}
	while (t--)
	{
		int p1, p2;
		cin >> p1 >> p2;
		swap(s[p1], s[p2]);
		swap(mp[s[p1]], mp[s[p2]]);
	}
	while (m--)
	{
		cin >> tmp;
		cout << mp[tmp] << endl;
	}

	return 0;
}